<template>
	<view>
		<view v-if="showEmpty" class="default-window">
			<u-empty></u-empty>
		</view>
		<view v-for="(item,index) in log" :key="index" class="card default-window flex place">
			<view>
				<view class="bold">{{item.remark}}</view>
				<view class="u-font-sm u-tips-color">{{item.time}}</view>
			</view>
			<view class="bold u-font-32" :class="{'add-style':item.symbol=='+' , 'reduce-style':item.symbol=='-'}">
				{{item.symbol}}{{item.num}}
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				log: [],
				page: 1,
				type: 0,
			};
		},
		computed: {
			showEmpty() {
				return this.log.length === 0 ? true : false
			}
		},
		onLoad({
			type
		}) {
			if (type === "0") {
				this.loadLog();
			} else {
				this.loadSpecialLog(type)
			}
		},

		onReachBottom() {
			this.loadLog();
		},
		methods: {
			loadLog() {
				this.$api('WalletLog/lists', {
					page: this.page,
				}, ).then(data => {
					if (data.status == 1) {
						this.page = this.page + 1;
						this.log = this.log.concat(data.data.wallet_log);

					} else {
						this.$showToast(data.msg);
					}
				});
			},

			loadSpecialLog(type) {
				this.$api('SpecialWalletLog/lists', {
					page: this.page,
					type: type,
				}, ).then(data => {
					if (data.status == 1) {
						this.page = this.page + 1;
						this.log = this.log.concat(data.data.special_wallet_log);

					} else {
						this.$showToast(data.msg);
					}
				});
			}

		}
	}
</script>

<style lang="scss">
	.add-style {
		color: #4CD964;
	}

	.reduce-style {
		color: #fa436a;
	}
</style>